package com.company.project.service.impl;

import javax.annotation.Resource;

import org.springframework.stereotype.Service;

import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import com.company.project.mapper.MatchTeamMapper;
import com.company.project.common.exception.BusinessException;
import com.company.project.entity.MatchTeamEntity;
import com.company.project.service.MatchTeamService;

@Service("matchTeamService")
public class MatchTeamServiceImpl extends ServiceImpl<MatchTeamMapper, MatchTeamEntity> implements MatchTeamService {

	@Resource
    private MatchTeamMapper matchTeamMapper;
	
	@Override
	public String addMatchTeam(MatchTeamEntity entity) {
		
		MatchTeamEntity teamOne = matchTeamMapper.selectOne(Wrappers.<MatchTeamEntity>lambdaQuery().eq(MatchTeamEntity::getTeamName, entity.getTeamName()));
        if (teamOne != null) {
            throw new BusinessException("团队名称已存在！");
        }	
		matchTeamMapper.insert(entity);
		return entity.getTeamId();
	}

	@Override
	public MatchTeamEntity getOne(String teamId) {		
		MatchTeamEntity entity = matchTeamMapper.selectById(teamId);
		return entity;
	}

}